
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>example</title>
</head>
<body>

<form>
    <input type="radio" name="test" value="dog"> 狗 <br>
    <input type="radio" name="test" value="cat" checked> 猫 <br>
    <input type="radio" name="test" value="pig"> 猪 <br>
</form>

<script src="../vendor/jquery-1.12.4.js"></script>
<script>
    //    var checkedValue;
    //    var elements = document.getElementsByTagName('input');
    //    for (var i = 0; i < elements.length; i++) {
    //        if (elements[i].type === 'radio' && elements[i].name === 'test' && elements[i].checked) {
    //            checkedValue = elements[i].value;
    //            break;
    //        }
    //    }
    //    console.log(checkedValue);
</script>
<script>
    var checkedValue = $('input:radio[name="test"]:checked').val();
    console.log(checkedValue);
    //$(domObject)---jQuery Object
    //$(xxx).get(0)---DOM Object
    //$(xxx)[0]---DOM Object
    //链式语法chaining
    //$('#divTest').text('Hello,world')
    //$('#divTest').removeClass('blue')
    //$('#divTest').addClass('bold')
    //$('#divTest').css('color','red')
</script>
</body>
</html>